{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post" enctype="">
            <div class="layui-form-item">
                <label class="layui-form-label">优惠券名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" value="{$data.name|default=''}" autocomplete="off" placeholder="请输入名称" lay-verify="required|name" class="layui-input">
                </div>
                <label class="layui-form-label">优惠券来源</label>
                <div class="layui-input-inline">
                    <select name="source">
                        <option value="">请选择来源</option>
                        <option value="1" {if condition="isset($data) and $data.source eq 1"}selected{/if}>新人注册</option>
                        <option value="2" {if condition="isset($data) and $data.source eq 2"}selected{/if}>签到赠送</option>
                        <option value="3" {if condition="isset($data) and $data.source eq 3"}selected{/if}>购物赠送</option>
                        <option value="4" {if condition="isset($data) and $data.source eq 4"}selected{/if}>邀请好友</option>
                        <option value="99" {if condition="isset($data) and $data.source eq 99"}selected{/if}>其他</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">优惠券图标</label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" id="test-upload-normal-img" src="{$data.img|default='__AD_IMG__/upload.png'}" width="50" height="50">
                    <input type="hidden" name="img" value="{$data.img|default=''}" autocomplete="off" placeholder="" class="layui-input">
                    <button type="button" class="layui-btn ajax-avatar"><i class="fa fa-file-image-o"></i> 上传图标</button>
                </div>
                <label class="layui-form-label">抵扣类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="1" title="现金" checked>
                    <input type="radio" name="type" value="2" title="运费" {if condition="isset($data.type) AND $data.type eq 1"}checked{/if}>
                    <input type="radio" name="type" value="3" title="积分" {if condition="isset($data.type) AND $data.type eq 2"}checked{/if}>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">满足条件</label>
                <div class="layui-input-inline">
                    <input type="text" name="condition" value="{$data.condition|default=''}" autocomplete="off" placeholder="请输入满足条件" lay-verify="" class="layui-input">
                </div>
                <label class="layui-form-label">优惠券金额</label>
                <div class="layui-input-inline">
                    <input type="text" name="price" value="{$data.price|default=''}" autocomplete="off" placeholder="请输入优惠券金额" lay-verify="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">发放数量</label>
                <div class="layui-input-inline">
                    <input type="text" name="stock" value="{$data.stock|default=''}" autocomplete="off" placeholder="请输入发放数量" lay-verify="" class="layui-input">
                </div>
                <label class="layui-form-label">店铺、供应商</label>
                <div class="layui-input-inline">
                    <select name="supplier_id">
                        <option value="0">自营</option>
                        {volist name="sup" id="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.supplier_id eq $v.id"}selected{/if}>{$v.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="start_time" value="{if condition='isset($data)'}{$data.start_time|date='Y-m-d H:i:s'}{/if}" class="layui-input" id="test5" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="end_time" value="{if condition='isset($data)'}{$data.end_time|date='Y-m-d H:i:s'}{/if}" class="layui-input" id="test6" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
layui.use('laydate', function(){
  var laydate = layui.laydate;

  //日期时间选择器
  laydate.render({
    elem: '#test5'
    ,type: 'datetime'
  });
  //日期时间选择器
  laydate.render({
    elem: '#test6'
    ,type: 'datetime'
  });
});
</script>
{/block}